#define idea_mul(r, a, b, ul)  \
	ul = (U32)a*b;	\
	if (ul != 0)	\
	{ \
		r = (ul&0xffff) - (ul>>16); \
		r -= ((r)>>16); \
	} \
	else {\
		r = (-(int)a-b+1); \
	} 

#define n2l(c, l)        (l  = ((U32)(*((c)++))) << 24L, \
                         l |= ((U32)(*((c)++))) << 16L, \
                         l |= ((U32)(*((c)++))) <<  8L, \
                         l |= ((U32)(*((c)++))))

#define l2n(l, c)        (*((c)++) = (U8)(((l)>>24L) & 0xff), \
                         *((c)++) = (U8)(((l)>>16L) & 0xff), \
                         *((c)++) = (U8)(((l)>> 8L) & 0xff), \
                         *((c)++) = (U8)(((l)     ) & 0xff))

#define n2s(c, l)		(l  = ((U32)(*((c)++))) << 8L, \
						 l |= ((U32)(*((c)++))) )

#define E_IDEA(num) \
	x1 &= 0xffff; \
	idea_mul(x1, x1, *p, ul); p++; \
	x2 += *(p++); \
	x3 += *(p++); \
	x4 &= 0xffff; \
	idea_mul(x4, x4, *p, ul); p++; \
	t0 = (x1^x3) & 0xffff; \
	idea_mul(t0, t0, *p, ul); p++; \
	t1 = (t0 + (x2^x4)) & 0xffff; \
	idea_mul(t1, t1, *p, ul); p++; \
	t0 += t1; \
	x1 ^= t1; \
	x4 ^= t0; \
	ul = x2^t0;  \
	x2 = x3^t1; \
	x3 = ul;

